home *** CD-ROM | disk | FTP | other *** search
/ NeXT Enterprise Objects Framework 1.1 / NeXT Enterprise Objects Framework 1.1.iso / NextDeveloper / Headers / eoaccess / EOFault.h < prev    next >
Encoding:
Text File  |  1995-02-10  |  5.3 KB  |  145 lines

  1. // EOFault.h
  2. // Copyright (c) 1994, NeXT Computer, Inc.  All rights reserved.
  3.  
  4. #import <foundation/NSArray.h>
  5. #import <foundation/NSData.h>
  6. #import <foundation/NSDictionary.h>
  7. #import <foundation/NSObject.h>
  8. #import <foundation/NSString.h>
  9.  
  10. @class EORelationship;
  11. @class EODatabaseChannel;
  12. @class EOQualifier;
  13. @class EOEntity;
  14.  
  15.  
  16. // An EOFault represents an Enterprise Object (or an array of Enterprise
  17. // Objects) that hasn't yet been fetched from the database.  When an object
  18. // that has relationships is fetched, EOFaults are created for the
  19. // destinations of those relationships (unless the corresponding objects have
  20. // already been fetched and uniqued).
  21. //
  22. // You can create a fault for a single object--called an "object fault"--or
  23. // for many objects described by a particular qualifier--called an "array
  24. // fault." To-one relationships result in object faults, while to-many
  25. // relationships result in array faults.  An object fault loads the real
  26. // object whenever you message it (with some exceptions; see MESSAGES THAT
  27. // DON'T CAUSE FETCHING below).  An array fault loads its objects as soon as
  28. // you send it any message that requires accessing the contents of the array
  29. // (-objectAtIndex:, -count, and so on).  Objects of either type are called
  30. // "fault objects".
  31. //
  32. // You can use fault objects to defer a fetch--that is, set up for a fetch
  33. // while your channel is in the middle of another operation.  For example,
  34. // your Enterprise Object may need to fetch objects in its
  35. // -takeValuesFromDictionary: method, but since -takeValuesFromDictionary: can
  36. // be invoked during a fetch, it has to defer its own fetch.
  37. //
  38. // Your Enterprise Object may also want to change the manner in which an array
  39. // fault fetches its objects.  If your Enterprise Object has an array fault
  40. // as one of its values, it can change its array fault's fetch order or
  41. // channel in its -awakeForDatabaseChannel: method.  (You can do this in
  42. // -takeValuesFromDictionary: too, but it's best to leave that method as
  43. // general as possible).
  44. //
  45. // MESSAGES THAT DON'T CAUSE FETCHING
  46. //
  47. // A fault object responds to the messages below as if it were the target
  48. // object without causing a fetch to happen.  For example, -class returns the
  49. // class of object that will be fetched, not EOFault.
  50. //
  51. // -dealloc
  52. // -retain
  53. // -retainCount
  54. // -release
  55. // -autorelease
  56. // -zone
  57. // -class
  58. // -isKindOfClass:
  59. // -isMemberOfClass:
  60. // -conformsToProtocol:
  61. // -respondsToSelector:
  62. // -isProxy
  63. // -description
  64. // -printForDebugger:
  65.  
  66.  
  67. @interface EOFault
  68. {
  69.     Class isa;
  70. }
  71.  
  72. + initialize;
  73. + (Class)class;
  74. + self;
  75. + retain;
  76. + (void)release;
  77. + autorelease;
  78. + (unsigned)retainCount;
  79. + (BOOL)respondsToSelector:(SEL)sel;
  80. + (void)doesNotRecognizeSelector:(SEL)sel;
  81. + forward:(SEL)sel :(marg_list)args;
  82.     // Basic class methods that every object needs to have.
  83.  
  84. + objectFaultWithPrimaryKey:(NSDictionary *)key
  85.     entity:(EOEntity *)entity 
  86.     databaseChannel:(EODatabaseChannel *)channel
  87.     zone:(NSZone *)zone;
  88.     // Returns an EOFault for the object with the specified primary key and
  89.     // entity. NOTE: this method retains the key rather than copies it.
  90.     // Consequently, the key arguement should not be modified after it is
  91.     // passed as an arguement to this method.
  92.  
  93. + (NSArray *)arrayFaultWithQualifier:(EOQualifier *)qualifier 
  94.     fetchOrder:(NSArray *)fetchOrder 
  95.     databaseChannel:(EODatabaseChannel *)channel
  96.     zone:(NSZone *)zone;
  97.     // Returns an NSArray which will select and fetch its objects
  98.     // according to qualifier and fetchOrder when it is accessed for the
  99.     // first time.
  100.  
  101. + (BOOL)isFault:object;
  102.     // Returns YES if object is a fault object, NO otherwise.  You should use
  103.     // this method if you need to know whether an object is in fact a fault
  104.     // object.
  105.  
  106. + (void)clearFault:fault;
  107.     // Turns fault into a freshly initialized instance of the target class.
  108.     // Does NOT fetch data for the new instance. This will raise if
  109.     // invoked with an object that isn't a fault object.  You'll rarely need
  110.     // to use this method.
  111.  
  112. + (Class)targetClassForFault:fault;
  113.     // Returns the class that will be instantiated when fault is fetched.
  114.  
  115. + (NSDictionary *)primaryKeyForFault:fault;
  116.     // Returns the primary key dictionary for an object fault, and nil for an
  117.     // array fault.
  118.  
  119. + (EOEntity *)entityForFault:fault;
  120.     // Returns the entity that fault was created with, or as determined by
  121.     // the qualifier for an array fault.  Returns nil if fault isn't a fault
  122.     // object.
  123.  
  124. + (EOQualifier *)qualifierForFault:fault;
  125.     // Returns the qualifier used to fetch the object(s) that fault was
  126.     // created for.  Returns nil if fault isn't a fault object.
  127.  
  128. + (NSArray *)fetchOrderForFault:fault;
  129.     // Returns the fetch order that fault was created with, or nil if
  130.     // fault isn't an array fault.
  131.  
  132. + (EODatabaseChannel *)databaseChannelForFault:fault;
  133.     // Returns the EODatabaseChannel that fault was created with.
  134.     // Returns nil if fault isn't a fault object.
  135.  
  136. @end
  137.  
  138.  
  139. @interface NSObject(EOUnableToFaultToOne)
  140. - (void)unableToFaultWithPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity databaseChannel:(EODatabaseChannel *)channel;
  141.     // Called when a fetch of a to-one fault does not return exactly one record.
  142.     // The default implementation raises an error.  Clients may override this
  143.     // method to properly initialize the object (or raise).
  144. @end
  145.